package org.example.component;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class UserService {
    //定义属性
    //加入 @Autowired , Spring容器时如何实现依赖注入?
    //也可以使用@Resource
    @Autowired
    private UserDao userDao;

    public void m1(){
        userDao.hi();
    }

    @PostConstruct //指定init方法是初始化方法
    public void init(){
        System.out.println("UserService-init()");
    }
}
